function e(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

var t = e(require("../../utils/api2")), i = e(require("../../public/utils/event-emitter")), s = void 0, n = void 0, a = void 0, r = {
    site: {
        renew: function() {
            "wxwork" === n.environment ? this.envTip() : (this.close(), wx.navigateTo({
                url: "/pages/site-create/renew/renew?sid=" + this.data.sid
            }));
        },
        share: function() {
            var e = this, t = this.data, i = t.sid, n = t.name, a = function() {
                return e.close();
            };
            s.onShareAppMessage = function() {
                return {
                    title: "“" + n + "”站点已到期，请及时续费",
                    path: "/pages/site-create/renew/renew?sid=" + i,
                    imageUrl: "/images/expire/renew.png",
                    success: a
                };
            };
        }
    },
    thirdparty: {
        renew: function() {
            var e = n, i = e.sid, s = e.appid;
            t.default.v4.qrcode.siterenew({
                query: {
                    sid: i,
                    appid: s
                }
            }).then(function(e) {
                wx.previewImage({
                    urls: [ e ]
                });
            });
        },
        share: function() {
            var e = this, t = this.data, i = t.sid, n = t.name, a = function() {
                return e.close();
            };
            s.onShareAppMessage = function() {
                return {
                    title: "“" + n + "”站点已到期，请及时续费",
                    path: "/pages/website/index/index?sid=" + i,
                    imageUrl: "/images/expire/renew.png",
                    success: a
                };
            };
        }
    }
};

Component({
    properties: {
        isExpireModalShown: {
            type: Boolean,
            observer: function(e) {
                this.setData({
                    isExpireModalShown: e
                });
            }
        },
        iscreator: {
            type: String,
            observer: function(e) {
                this.setData({
                    iscreator: e
                });
            }
        },
        sid: Number,
        name: String,
        expiretime: {
            type: String,
            observer: "checkExpiration"
        }
    },
    data: {
        isInSettings: !1,
        isExpireModalShown: !1,
        isCloseBtnShown: !1,
        text: {
            title: "站点已到期",
            subTitle: "该站点已到期，暂时无法访问。",
            renew: "我帮Ta续费"
        }
    },
    created: function() {
        n = getApp().globalData;
    },
    methods: {
        checkExpiration: function(e) {
            var t = Date.now() > Date.parse(e.split(" ")[0]), i = getCurrentPages(), o = "pages/website/settings/settings" === (s = i[i.length - 1]).route, p = "thirdparty" === n.app, c = "site" === n.app;
            if (t && (o || p || c)) {
                this.setData({
                    isExpireModalShown: !0
                }), c && o && this.setData({
                    isInSettings: !0,
                    text: {
                        title: "续费通知",
                        subTitle: "您的站点已到期，生成的独立小程序将无法访问，请及时续费。",
                        renew: "立即续费"
                    }
                });
                var u = s.onShareAppMessage;
                a = u, r[n.app].share.call(this);
            }
        },
        delete: function() {
            var e = this.data.sid;
            wx.showModal({
                title: "删除官网",
                content: "删除后，官网数据将无法恢复，确认删除？",
                success: function(s) {
                    s.confirm && t.default.site.site.delete({
                        data: {
                            sid: e
                        }
                    }).then(function() {
                        wx.showToast({
                            title: "删除成功",
                            mask: !0,
                            success: function() {
                                setTimeout(function() {
                                    i.default.emit("list.refresh"), wx.switchTab({
                                        url: "/pages/index/index"
                                    });
                                }, 1500);
                            }
                        });
                    });
                }
            });
        },
        close: function() {
            this.setData({
                isExpireModalShown: !1
            }), s.onShareAppMessage = a;
        },
        renew: function() {
            r[n.app].renew.call(this);
        },
        envTip: function() {
            wx.showModal({
                title: "续费提示",
                content: "企业微信内暂不支持升级续费官网",
                confirmText: "我知道了",
                showCancel: !1
            });
        }
    }
});